package com.nanfang51g3.ckz.ui.index;

import android.content.Context;
import android.location.Location;
import android.location.LocationListener;
import android.os.Bundle;

import com.nanfang51g3.ckz.utils.KLog;

/**
 * Created by Administrator on 2016/4/26.
 */
public class LocationServerListener implements LocationListener {

    IndexContract.IndexActionsListener indexActionsListener;
    Context context;

    public LocationServerListener(Context context, IndexContract.IndexActionsListener indexActionsListener) {
        this.context = context;
        this.indexActionsListener = indexActionsListener;
    }


    public void onLocationChanged(Location location) {
//        EasyToast.showShort(context, "\"跳了\"" +
//                new DecimalFormat("###.00").format(location.getLatitude())
//                + "-" +
//                new DecimalFormat("###.00").format(location.getLongitude()));
        /**
         * @see IndexPresenter#updateWithNewLocation(Location)
         */
        if (location != null) {
            indexActionsListener.updateWithNewLocation(location);
        }
        KLog.e("LocationServerListener", "onLocationChanged=Long-" + location.getLatitude() + "&Long-" + location.getLongitude());
    }

    public void onProviderDisabled(String provider) {
        /**
         * @see IndexPresenter#updateWithNewLocation(Location)
         */
//        indexActionsListener.updateWithNewLocation(null);
        KLog.e("LocationServerListener", "onProviderDisabled=" + provider);
    }

    public void onProviderEnabled(String provider) {
        KLog.e("LocationServerListener", "onProviderEnabled=" + provider);
    }

    public void onStatusChanged(String provider, int status, Bundle extras) {
        KLog.e("LocationServerListener", "onStatusChanged=" + provider + "-" + status + "-" + extras.toString());
    }
}
